﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;

namespace ProjectA.Modules.Configuracion.Usuarios
{
    public class cUsuario
    {
        public int UserID { get; set; }
        public string UserName { get; set; }
        public string FirstName { get; set; }
        public string SecondName { get; set; }
        public string FirstLastName { get; set; }
        public string SecondLastName { get; set; }
        public string Password { get; set; }
        public DateTime CreationDate { get; set; }
        public DateTime ModificationDate { get; set; }
        public bool UserState { get; set; }
        public string Role { get; set; }

        public cUsuario()
        {
        }

        public void LoadUserInfo(DataSet dsUserData)
        {
            if (dsUserData.Tables.Count > 0)
            {
                UserID = Convert.ToInt32(dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["ID"]]);
                UserName = dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["UserName"]].ToString();
                Password = dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["Password"]].ToString();
                FirstName = dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["FirstName"]].ToString();
                SecondName = dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["SecondName"]].ToString();
                FirstLastName = dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["FirstLastName"]].ToString();
                SecondLastName = dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["SecondLastName"]].ToString();
                CreationDate = Convert.ToDateTime(dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["CreationDate"]].ToString());
                ModificationDate = Convert.ToDateTime(dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["ModificationDate"]].ToString());
                if (dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["State"]].ToString() == "0")
                    UserState = false;
                else
                    UserState = true;
                Role = dsUserData.Tables[0].Rows[0][dsUserData.Tables[0].Columns["Role"]].ToString();
            }
        }
    }
}